﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BGSpaceShooter;
using Microsoft.Xna.Framework.Input;

namespace BGSpaceShooterServer
{
    internal class GameStateController
    {
        public GameStateController()
        {
            GameStateComputer = new GameStateComputer();
        }

        public GameStateComputer GameStateComputer
        {
            get;
            set;
        }

        public void UpdatePlayerInput(Player player, List<Keys> userInput)
        {
            player.SetLastInput(userInput, DateTime.Now);
        }

        public void Update(IEnumerable<Player> players, IEnumerable<Projectile> projectiles)
        {
            lock (players)
            {
                foreach (Player player in players)
                {
                    GameStateComputer.CalculateMove(player);
                }
                GameStateComputer.CalculateCollisions(players, projectiles);
            }
        }



    }
}
